c#里 方法或类 前面的[ ]是什么意思?

来源:百度知道 编辑:UC知道 时间:2024/05/28 07:50:58
给个解释的连接就行 多谢
如:
[DataTable("Association")]
public class Association
{
Int32 _ID;
[KeyField("ID")]
public Int32 ID
{
get { return this._ID; }
set { this._ID = value; }
}
}

请参考
http://www.pconline.com.cn/pcjob/process/other/others/0409/445997.html

这是东西叫属性(attribute),你可以参考msdn,或者这里
http://msdn.microsoft.com/library/chs/default.asp?url=/library/CHS/csref/html/vcwlkattributestutorial.asp

比如我们可以用一个过时属性来声明一个类,说明他是过时了,不应该再使用,编译时自动弹出一个警告。参考Obsolete属性。